package com.breezelin.freshmarket.entities.rsp;

/**
 * Created by Breeze Lin
 * 2016/9/26 16:06
 * breezesummerlin@163.com
 */

import com.breezelin.freshmarket.entities.JsonStruct;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 搜索热词响应
 */
public class HotWordRsp implements JsonStruct {

	/*
	"Body": {
    "HotWords": [
      "原箱",
      "大闸蟹",
      "奇异果",
      "火龙果",
      "牛肉",
      "三文鱼",
      "苹果",
      "葡萄",
      "虾仁",
      "梨",
      "芒果"
    ]
  }
	 */

	/**
	 * 热词集合
	 */
	private List<String> hotWords;

	/**
	 * @return 搜索热词
	 */
	public List<String> getHotWords() {
		return hotWords;
	}

	@Override
	public void fromJson(JSONObject jsonObject) {
		hotWords = new ArrayList<>();
		JSONArray jsonArray = jsonObject.optJSONArray("HotWords");
		if (jsonArray != null) {
			for (int i = 0; i < jsonArray.length(); i++) {
				hotWords.add(jsonArray.optString(i));
			}
		}
	}

	@Override
	public JSONObject toJson() {
		return null;
	}
}
